package com.hanfeng.client.view;

import android.app.Activity;
import android.content.Intent;
import android.os.Bundle;
import android.view.Window;
import android.view.WindowManager;
import android.view.animation.Animation;
import android.view.animation.Animation.AnimationListener;
import android.view.animation.AnimationUtils;
import android.widget.ImageView;

/**
 * 启动动画跳转主界面Activity
 * 
 * @author hanfeng
 * @data 2012-8-30 上午10:26:44
 */
public class SplashActivity extends Activity {
	@Override
	protected void onCreate(Bundle savedInstanceState) {
		super.onCreate(savedInstanceState);
		// 取消标题栏
		this.requestWindowFeature(Window.FEATURE_NO_TITLE);
		// 设置全屏
		this.getWindow().setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN,
				WindowManager.LayoutParams.FLAG_FULLSCREEN);
		//设置Activity布局
		setContentView(R.layout.welcome_loading);
		//实例化ImageView
		ImageView ivSplash  = (ImageView)findViewById(R.id.logo);
		//实例动画对象
		Animation animation = AnimationUtils.loadAnimation(this, R.anim.logo);
		//启动动画
		ivSplash.startAnimation(animation);
		//设置动画显示时间，单位毫秒
		animation.setDuration(3000);
		//设置动画监听器
		animation.setAnimationListener(new AnimationListener() {
			
			@Override
			public void onAnimationStart(Animation animation) {
				// TODO Auto-generated method stub
				
			}
			
			@Override
			public void onAnimationRepeat(Animation animation) {
				// TODO Auto-generated method stub
				
			}
			
			@Override
			public void onAnimationEnd(Animation animation) {
				//动画结束时候跳转到播放器主界面
				Intent intent = new Intent(SplashActivity.this,MainActivity.class);
				startActivity(intent);
				//结束动画Activity
				SplashActivity.this.finish();				
			}
		});
	}
}
